package com.bafa.front.presentationbeans;

import com.bafa.debug.Debug;
import com.bafa.objects.team.Team;
import com.bafa.objects.team.TeamSeasonStats;
import com.bafa.services.RetrieveServices;

public class TeamBean implements Comparable{

	private int id;

	private String name = "";

	private String primaryContactName = "";

	private String primaryContactEmail = "";

	private String primaryContactTel = "";

	private String secondaryContactName = "";

	private String secondaryContactEmail = "";

	private String secondaryContactTel = "";

	private String shirtColour = "";

	private double moneyOwed;

	private TeamMatchListBean matches;
	private PlayerListBean scorers;
	
	public TeamBean(Team team,int seasonId){
		this(team.getId(),team.getName(),team.getPrimaryContactName(),team.getPrimaryContactEmail(),team.getPrimaryContactTel(),team.getSecondaryContactName(),team.getSecondaryContactEmail(),team.getSecondaryContactTel(),team.getShirtColour(),team.getMoneyOwed(),seasonId);
	}
	public TeamBean(int id, String name, String contactname1, String email1, String tel1, String contactname2, String email2, String tel2, String colour, double owed, int seasonId) {
		super();
		// TODO Auto-generated constructor stub
		this.id = id;
		this.name = name;
		primaryContactName = contactname1;
		primaryContactEmail = email1;
		primaryContactTel = tel1;
		secondaryContactName = contactname2;
		secondaryContactEmail = email2;
		secondaryContactTel = tel2;
		shirtColour = colour;
		moneyOwed = owed;
		
		if(seasonId>0){
			Team team = RetrieveServices.getTeam(""+id);
			TeamSeasonStats seasonStats = ((TeamSeasonStats)team.getStats().getSeasonStats().get(seasonId));
			Debug.debug(this.getClass(),"TeamBean","SeasonStats "+seasonStats);
			matches = new TeamMatchListBean(seasonStats.getMatches(),id); 
			Debug.debug(this.getClass(),"TeamBean","Matches "+matches);
			Debug.debug(this.getClass(),"TeamBean","Scorers "+seasonStats.scorers());
			scorers = new PlayerListBean(seasonStats.scorers(),seasonId,id,true);
			Debug.debug(this.getClass(),"TeamBean","Scorers "+scorers);
		}
	}

	public int compareTo(Object arg0) {
		TeamBean bean = (TeamBean)arg0;
		return this.name.compareToIgnoreCase(bean.getName());
		
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public TeamMatchListBean getMatches() {
		return matches;
	}

	public void setMatches(TeamMatchListBean matches) {
		this.matches = matches;
	}

	public double getMoneyOwed() {
		return moneyOwed;
	}

	public void setMoneyOwed(double moneyOwed) {
		this.moneyOwed = moneyOwed;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPrimaryContactEmail() {
		return primaryContactEmail;
	}

	public void setPrimaryContactEmail(String primaryContactEmail) {
		this.primaryContactEmail = primaryContactEmail;
	}

	public String getPrimaryContactName() {
		return primaryContactName;
	}

	public void setPrimaryContactName(String primaryContactName) {
		this.primaryContactName = primaryContactName;
	}

	public String getPrimaryContactTel() {
		return primaryContactTel;
	}

	public void setPrimaryContactTel(String primaryContactTel) {
		this.primaryContactTel = primaryContactTel;
	}

	public PlayerListBean getScorers() {
		return scorers;
	}

	public void setScorers(PlayerListBean scorers) {
		this.scorers = scorers;
	}

	public String getSecondaryContactEmail() {
		return secondaryContactEmail;
	}

	public void setSecondaryContactEmail(String secondaryContactEmail) {
		this.secondaryContactEmail = secondaryContactEmail;
	}

	public String getSecondaryContactName() {
		return secondaryContactName;
	}

	public void setSecondaryContactName(String secondaryContactName) {
		this.secondaryContactName = secondaryContactName;
	}

	public String getSecondaryContactTel() {
		return secondaryContactTel;
	}

	public void setSecondaryContactTel(String secondaryContactTel) {
		this.secondaryContactTel = secondaryContactTel;
	}

	public String getShirtColour() {
		return shirtColour;
	}

	public void setShirtColour(String shirtColour) {
		this.shirtColour = shirtColour;
	}
	
	

}
